public class Solution896 {
    public boolean isMonotonic(int[] nums) {
        boolean flag=true;
        for (int i=0;i<nums.length-1;i++){
            if (nums[i]>nums[i+1]){
                flag=false;
            }
        }
        if (flag){
            return true;
        }
        flag=true;
        for (int i=0;i<nums.length-1;i++){
            if (nums[i]<nums[i+1]){
                flag=false;
            }
        }
        return flag;
    }

    public static void main(String[] args) {
        System.out.println(new Solution896().isMonotonic(new int[]{1,2,2,3}));
    }
}
